import service from "@/utils/request";
import type { AttrItem } from "./model/attrModel";
import type { categoryList } from "./model/cartgroyselectModel";

enum Api {
  getCartgroy1ListUrl = "/admin/product/getCategory1",
  getCartgroy2ListUrl = "/admin/product/getCategory2",
  getCartgroy3ListUrl = "/admin/product/getCategory3",
  getAddAttrListUrl = "/admin/product/saveAttrInfo",
}

export const getCartgroy1ListApi = () => {
  return service.get<any, categoryList>(Api.getCartgroy1ListUrl);
};

export const getCartgroy2ListApi = (category1Id: number) => {
  return service.get<any, categoryList>(
    Api.getCartgroy2ListUrl + `/${category1Id}`
  );
};

export const getCartgroy3ListApi = (category2Id: number) => {
  return service.get<any, categoryList>(
    Api.getCartgroy3ListUrl + `/${category2Id}`
  );
};

export const getAddAttrListApi = (baseAttrInfo: AttrItem) => {
  return service.post<any, null>(Api.getAddAttrListUrl, baseAttrInfo);
};
